package com.example.myapplication.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * 缩放
 *
 * 作者：李祥
 * 邮箱：499194689@qq.com
 */

public class TestView03 extends View {
    int mH;
    int mW;
    Paint paint=new Paint();

    public TestView03(Context context) {
        super(context);
    }

    public TestView03(Context context,  AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mH = h;
        mW = w;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.translate(mW / 2, mH / 2);
        RectF rectF = new RectF(-200, -200, 200, 200);
        paint.setStyle(Paint.Style.STROKE);
        for (int i = 0; i <= 18; i++) {
                canvas.scale(0.9f, 0.9f,30,30);
                canvas.drawRect(rectF,paint);
        }
    }

}